package org.particlethink.response;

import io.swagger.v3.oas.annotations.media.Schema;
import org.particlethink.entry.DeliverStatus;
import org.particlethink.model.*;

import java.util.Date;

public class DeliverResponse {
    private Integer id;
    @Schema(description = "发货单编号")
    private String no;
    @Schema(description = "物料大类")
    private CategoryResponse category;
    @Schema(description = "验收")
    private AcceptanceResponse acceptance;
    @Schema(description = "状态 1:待验收 2:待确认 3:已入库 4:已对账 5:供应商异议 6:已作废 7:供货商终止订单")
    private DeliverStatus status;
    @Schema(description = "发货人(供应商用户)")
    private SupplierUserResponse creator;


    @Schema(description = "供应商")
    private SupplierResponse supplier;

    @Schema(description = "供货商备注")
    private String remark;//待验收备注


    @Schema(description = "项目")
    private ProjectResponse project;

    @Schema(description = "订单编号")
    private String orderNo;//订单id

    @Schema(description = "批次计划编号")
    private String batchPlanNo;//批次计划编号
    @Schema(description = "总计划编号")
    private String masterPlanNo;//总计划编号


    @Schema(description = "发货时间")
    private Date createAt;
    @Schema(description = "预计到达时间")
    private Date finishAt;

    @Schema(description = "供应商确认时间")
    private Date confirmAt; // 供应商确认时间
    @Schema(description = "对账时间")
    private Date billAt;  //对账时间

    @Schema(description = "项目备注")
    private String projectRemark;//验收备注


    @Schema(description = "供应商异议")
    private String objectionRemark;


    public DeliverResponse() {
    }


    public DeliverResponse(
            Deliver deliver,
            Project project,
            Category category,
            SupplierUser creator,
            Supplier supplier,
            Acceptance acceptance,
            ProjectUser acceptanceCreator
    ) {
        this.confirmAt = deliver.getConfirmAt();
        this.billAt = deliver.getBillAt();
        this.id = deliver.getId();
        this.no = deliver.getNo();
        this.project = new ProjectResponse(project);
        this.finishAt = deliver.getFinishAt();
        this.status = deliver.getStatus();
        if (acceptance != null) {
            this.acceptance = new AcceptanceResponse(acceptance, acceptanceCreator);
        }
        this.orderNo = deliver.getOrderNo();
        this.batchPlanNo = deliver.getBatchPlanNo();
        this.masterPlanNo = deliver.getMasterPlanNo();
        this.category = new CategoryResponse(category);
        this.creator = new SupplierUserResponse(creator);
        this.supplier = new SupplierResponse(supplier);
        this.createAt = deliver.getCreatedAt();
        this.remark = deliver.getRemark();
        this.projectRemark = acceptance == null ? "" : acceptance.getSuggestion();
        this.objectionRemark = deliver.getObjectionReason();
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public DeliverStatus getStatus() {
        return status;
    }

    public void setStatus(DeliverStatus status) {
        this.status = status;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public ProjectResponse getProject() {
        return project;
    }

    public void setProject(ProjectResponse project) {
        this.project = project;
    }


    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public CategoryResponse getCategory() {
        return category;
    }

    public void setCategory(CategoryResponse category) {
        this.category = category;
    }

    public SupplierUserResponse getCreator() {
        return creator;
    }

    public void setCreator(SupplierUserResponse creator) {
        this.creator = creator;
    }


    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public Date getFinishAt() {
        return finishAt;
    }

    public void setFinishAt(Date finishAt) {
        this.finishAt = finishAt;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getBatchPlanNo() {
        return batchPlanNo;
    }

    public void setBatchPlanNo(String batchPlanNo) {
        this.batchPlanNo = batchPlanNo;
    }

    public String getMasterPlanNo() {
        return masterPlanNo;
    }

    public void setMasterPlanNo(String masterPlanNo) {
        this.masterPlanNo = masterPlanNo;
    }

    public String getProjectRemark() {
        return projectRemark;
    }

    public void setProjectRemark(String projectRemark) {
        this.projectRemark = projectRemark;
    }

    public Date getConfirmAt() {
        return confirmAt;
    }

    public void setConfirmAt(Date confirmAt) {
        this.confirmAt = confirmAt;
    }

    public Date getBillAt() {
        return billAt;
    }

    public void setBillAt(Date billAt) {
        this.billAt = billAt;
    }

    public AcceptanceResponse getAcceptance() {
        return acceptance;
    }

    public void setAcceptance(AcceptanceResponse acceptance) {
        this.acceptance = acceptance;
    }

    public SupplierResponse getSupplier() {
        return supplier;
    }

    public void setSupplier(SupplierResponse supplier) {
        this.supplier = supplier;
    }

    public String getObjectionRemark() {
        return objectionRemark;
    }

    public void setObjectionRemark(String objectionRemark) {
        this.objectionRemark = objectionRemark;
    }
}
